{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "8ad29cdc",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "# 创建示例DataFrame\n",
    "data = {\n",
    "    '姓名': ['张三', '李四', '王五', '赵六', '钱七'],\n",
    "    '年龄': [25, 30, 35, 28, 32],\n",
    "    '城市': ['北京', '上海', '广州', '深圳', '北京'],\n",
    "    '薪资': [15000, 20000, 25000, 18000, 22000]\n",
    "}\n",
    "df = pd.DataFrame(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6d2b15f4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    张三\n",
       "1    李四\n",
       "2    王五\n",
       "3    赵六\n",
       "4    钱七\n",
       "Name: 姓名, dtype: object"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用 iloc 基于索引的访问,特别注意,如果要指定列,可以用get_loc('ColumnName')获取列的数字索引\n",
    "df.iloc[:, df.columns.get_loc('姓名')]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c5377570",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    张三\n",
       "1    李四\n",
       "2    王五\n",
       "3    赵六\n",
       "4    钱七\n",
       "Name: 姓名, dtype: object"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['姓名']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4b067f91",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    张三\n",
       "1    李四\n",
       "2    王五\n",
       "3    赵六\n",
       "4    钱七\n",
       "Name: 姓名, dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[:, df.columns.get_loc('姓名')]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "104d6959",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['姓名', '年龄', '城市', '薪资'], dtype='object')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "e1e23ff8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RangeIndex(start=0, stop=5, step=1)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "3f9061d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "姓名",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "年龄",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "城市",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "薪资",
         "rawType": "int64",
         "type": "integer"
        }
       ],
       "conversionMethod": "pd.DataFrame",
       "ref": "6699656e-8fc5-4431-987b-e1ab1b75e5d8",
       "rows": [
        [
         "0",
         "张三",
         "25",
         "北京",
         "15000"
        ],
        [
         "1",
         "李四",
         "30",
         "上海",
         "20000"
        ],
        [
         "4",
         "钱七",
         "32",
         "北京",
         "22000"
        ]
       ],
       "shape": {
        "columns": 4,
        "rows": 3
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>姓名</th>\n",
       "      <th>年龄</th>\n",
       "      <th>城市</th>\n",
       "      <th>薪资</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>张三</td>\n",
       "      <td>25</td>\n",
       "      <td>北京</td>\n",
       "      <td>15000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>李四</td>\n",
       "      <td>30</td>\n",
       "      <td>上海</td>\n",
       "      <td>20000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>钱七</td>\n",
       "      <td>32</td>\n",
       "      <td>北京</td>\n",
       "      <td>22000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   姓名  年龄  城市     薪资\n",
       "0  张三  25  北京  15000\n",
       "1  李四  30  上海  20000\n",
       "4  钱七  32  北京  22000"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[pd.Series([True,True,False,False,True])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "fc5d2a4a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     True\n",
       "1    False\n",
       "2    False\n",
       "3     True\n",
       "4    False\n",
       "Name: 年龄, dtype: bool"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['年龄']<30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "e76d96c9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     True\n",
       "1     True\n",
       "2    False\n",
       "3    False\n",
       "4    False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Series([True,True,False,False,False])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "c87ae2cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "姓名",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "年龄",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "城市",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "薪资",
         "rawType": "int64",
         "type": "integer"
        }
       ],
       "conversionMethod": "pd.DataFrame",
       "ref": "e8742281-1bc9-4290-8b18-18a8131f4fb0",
       "rows": [
        [
         "0",
         "张三",
         "25",
         "北京",
         "15000"
        ],
        [
         "1",
         "李四",
         "30",
         "上海",
         "20000"
        ],
        [
         "4",
         "钱七",
         "32",
         "北京",
         "22000"
        ]
       ],
       "shape": {
        "columns": 4,
        "rows": 3
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>姓名</th>\n",
       "      <th>年龄</th>\n",
       "      <th>城市</th>\n",
       "      <th>薪资</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>张三</td>\n",
       "      <td>25</td>\n",
       "      <td>北京</td>\n",
       "      <td>15000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>李四</td>\n",
       "      <td>30</td>\n",
       "      <td>上海</td>\n",
       "      <td>20000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>钱七</td>\n",
       "      <td>32</td>\n",
       "      <td>北京</td>\n",
       "      <td>22000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   姓名  年龄  城市     薪资\n",
       "0  张三  25  北京  15000\n",
       "1  李四  30  上海  20000\n",
       "4  钱七  32  北京  22000"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[[0,1,4],:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0f3a63c9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "姓名",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "年龄",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "城市",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "薪资",
         "rawType": "int64",
         "type": "integer"
        }
       ],
       "conversionMethod": "pd.DataFrame",
       "ref": "ccd90ef8-d407-4389-a0ed-0078cedee248",
       "rows": [
        [
         "0",
         "张三",
         "25",
         "北京",
         "15000"
        ],
        [
         "1",
         "李四",
         "30",
         "上海",
         "20000"
        ],
        [
         "4",
         "钱七",
         "32",
         "北京",
         "22000"
        ]
       ],
       "shape": {
        "columns": 4,
        "rows": 3
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>姓名</th>\n",
       "      <th>年龄</th>\n",
       "      <th>城市</th>\n",
       "      <th>薪资</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>张三</td>\n",
       "      <td>25</td>\n",
       "      <td>北京</td>\n",
       "      <td>15000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>李四</td>\n",
       "      <td>30</td>\n",
       "      <td>上海</td>\n",
       "      <td>20000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>钱七</td>\n",
       "      <td>32</td>\n",
       "      <td>北京</td>\n",
       "      <td>22000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   姓名  年龄  城市     薪资\n",
       "0  张三  25  北京  15000\n",
       "1  李四  30  上海  20000\n",
       "4  钱七  32  北京  22000"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[[0,1,],:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "42240b6c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "姓名",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "年龄",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "城市",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "薪资",
         "rawType": "int64",
         "type": "integer"
        }
       ],
       "conversionMethod": "pd.DataFrame",
       "ref": "007dfba6-9cc2-4315-a51c-47fc6b0e6874",
       "rows": [
        [
         "0",
         "张三",
         "25",
         "北京",
         "15000"
        ],
        [
         "1",
         "李四",
         "30",
         "上海",
         "20000"
        ],
        [
         "4",
         "钱七",
         "32",
         "北京",
         "22000"
        ]
       ],
       "shape": {
        "columns": 4,
        "rows": 3
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>姓名</th>\n",
       "      <th>年龄</th>\n",
       "      <th>城市</th>\n",
       "      <th>薪资</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>张三</td>\n",
       "      <td>25</td>\n",
       "      <td>北京</td>\n",
       "      <td>15000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>李四</td>\n",
       "      <td>30</td>\n",
       "      <td>上海</td>\n",
       "      <td>20000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>钱七</td>\n",
       "      <td>32</td>\n",
       "      <td>北京</td>\n",
       "      <td>22000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   姓名  年龄  城市     薪资\n",
       "0  张三  25  北京  15000\n",
       "1  李四  30  上海  20000\n",
       "4  钱七  32  北京  22000"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[(df[\"城市\"] == \"上海\") | (df[\"城市\"] == \"北京\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "478983ff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     True\n",
       "1     True\n",
       "2    False\n",
       "3    False\n",
       "4     True\n",
       "Name: 城市, dtype: bool"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s=(df[\"城市\"] == \"上海\") | (df[\"城市\"] == \"北京\")\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "cbf7b9f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "姓名",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "年龄",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "城市",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "薪资",
         "rawType": "int64",
         "type": "integer"
        }
       ],
       "conversionMethod": "pd.DataFrame",
       "ref": "9fa88235-b044-4d59-a96f-f080280761fb",
       "rows": [
        [
         "0",
         "张三",
         "25",
         "北京",
         "15000"
        ],
        [
         "1",
         "李四",
         "30",
         "上海",
         "20000"
        ],
        [
         "4",
         "钱七",
         "32",
         "北京",
         "22000"
        ]
       ],
       "shape": {
        "columns": 4,
        "rows": 3
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>姓名</th>\n",
       "      <th>年龄</th>\n",
       "      <th>城市</th>\n",
       "      <th>薪资</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>张三</td>\n",
       "      <td>25</td>\n",
       "      <td>北京</td>\n",
       "      <td>15000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>李四</td>\n",
       "      <td>30</td>\n",
       "      <td>上海</td>\n",
       "      <td>20000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>钱七</td>\n",
       "      <td>32</td>\n",
       "      <td>北京</td>\n",
       "      <td>22000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   姓名  年龄  城市     薪资\n",
       "0  张三  25  北京  15000\n",
       "1  李四  30  上海  20000\n",
       "4  钱七  32  北京  22000"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[[0,1,4]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "25355a4b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "姓名",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "年龄",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "城市",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "薪资",
         "rawType": "int64",
         "type": "integer"
        }
       ],
       "conversionMethod": "pd.DataFrame",
       "ref": "d0f49bc8-18f1-4091-ab00-b039ae07fd00",
       "rows": [
        [
         "0",
         "张三",
         "25",
         "北京",
         "15000"
        ],
        [
         "1",
         "李四",
         "30",
         "上海",
         "20000"
        ],
        [
         "4",
         "钱七",
         "32",
         "北京",
         "22000"
        ]
       ],
       "shape": {
        "columns": 4,
        "rows": 3
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>姓名</th>\n",
       "      <th>年龄</th>\n",
       "      <th>城市</th>\n",
       "      <th>薪资</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>张三</td>\n",
       "      <td>25</td>\n",
       "      <td>北京</td>\n",
       "      <td>15000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>李四</td>\n",
       "      <td>30</td>\n",
       "      <td>上海</td>\n",
       "      <td>20000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>钱七</td>\n",
       "      <td>32</td>\n",
       "      <td>北京</td>\n",
       "      <td>22000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   姓名  年龄  城市     薪资\n",
       "0  张三  25  北京  15000\n",
       "1  李四  30  上海  20000\n",
       "4  钱七  32  北京  22000"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s=[True,True,False,False,True]\n",
    "df[pd.Series(s)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "7c746ef9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "姓名",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "年龄",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "城市",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "薪资",
         "rawType": "int64",
         "type": "integer"
        }
       ],
       "conversionMethod": "pd.DataFrame",
       "ref": "8ae1c55b-d0f1-4898-bea6-36e9f0d1bde2",
       "rows": [
        [
         "0",
         "张三",
         "25",
         "北京",
         "15000"
        ],
        [
         "1",
         "李四",
         "30",
         "上海",
         "20000"
        ],
        [
         "4",
         "钱七",
         "32",
         "北京",
         "22000"
        ]
       ],
       "shape": {
        "columns": 4,
        "rows": 3
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>姓名</th>\n",
       "      <th>年龄</th>\n",
       "      <th>城市</th>\n",
       "      <th>薪资</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>张三</td>\n",
       "      <td>25</td>\n",
       "      <td>北京</td>\n",
       "      <td>15000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>李四</td>\n",
       "      <td>30</td>\n",
       "      <td>上海</td>\n",
       "      <td>20000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>钱七</td>\n",
       "      <td>32</td>\n",
       "      <td>北京</td>\n",
       "      <td>22000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   姓名  年龄  城市     薪资\n",
       "0  张三  25  北京  15000\n",
       "1  李四  30  上海  20000\n",
       "4  钱七  32  北京  22000"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s=[True,True,False,False,True]\n",
    "df[s]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "acef6896",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "姓名",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "年龄",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "城市",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "薪资",
         "rawType": "int64",
         "type": "integer"
        }
       ],
       "conversionMethod": "pd.DataFrame",
       "ref": "c91cd692-ccd2-4a72-96bd-45314b8ce213",
       "rows": [
        [
         "0",
         "张三",
         "25",
         "北京",
         "15000"
        ],
        [
         "1",
         "李四",
         "30",
         "上海",
         "20000"
        ],
        [
         "4",
         "钱七",
         "32",
         "北京",
         "22000"
        ]
       ],
       "shape": {
        "columns": 4,
        "rows": 3
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>姓名</th>\n",
       "      <th>年龄</th>\n",
       "      <th>城市</th>\n",
       "      <th>薪资</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>张三</td>\n",
       "      <td>25</td>\n",
       "      <td>北京</td>\n",
       "      <td>15000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>李四</td>\n",
       "      <td>30</td>\n",
       "      <td>上海</td>\n",
       "      <td>20000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>钱七</td>\n",
       "      <td>32</td>\n",
       "      <td>北京</td>\n",
       "      <td>22000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   姓名  年龄  城市     薪资\n",
       "0  张三  25  北京  15000\n",
       "1  李四  30  上海  20000\n",
       "4  钱七  32  北京  22000"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[[True,True,False,False,True]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "38b521c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pandas.core.strings.accessor.StringMethods at 0x1fe07638950>"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['城市'].str"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4bc1ff8a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "dates = pd.date_range(\"20130101\", periods=6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "9d4a1884",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.indexes.datetimes.DatetimeIndex"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(dates)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "37c55f0b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2013-01-01 00:00:00')"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dates[0]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
